<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>名片管理系统 - 名片夹管理</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f4f4f4;
      margin: 0;
      padding: 20px;
    }

    .container {
      max-width: 1000px;
      margin: 0 auto;
      background-color: white;
      padding: 20px;
      border-radius: 5px;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }

    .header {
      background-color: #007bff;
      color: white;
      padding: 15px 0;
      text-align: center;
      margin-bottom: 20px;
    }

    .back-link {
      display: block;
      margin-bottom: 20px;
      color: #007bff;
      text-decoration: none;
    }
    
    .back-link:hover {
      text-decoration: underline;
    }

    .actions {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
    }

    button {
      background-color: #007bff;
      color: white;
      border: none;
      padding: 10px 20px;
      border-radius: 3px;
      cursor: pointer;
    }

    button:hover {
      background-color: #0056b3;
    }

    button.danger {
      background-color: #dc3545;
    }

    button.danger:hover {
      background-color: #c82333;
    }

    button.success {
      background-color: #28a745;
    }
    
    button.success:hover {
      background-color: #218838;
    }

    .button-group button {
      margin-left: 10px;
    }

    table {
      width: 100%;
      border-collapse: collapse;
    }

    th, td {
      padding: 12px 15px;
      text-align: left;
      border-bottom: 1px solid #ddd;
    }

    thead tr {
      background-color: #f8f9fa;
      border-bottom: 2px solid #ddd;
    }

    tr:hover {
      background-color: #f8f9fa;
    }

    .modal {
      display: none;
      position: fixed;
      z-index: 1;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      overflow: auto;
      background-color: rgba(0, 0, 0, 0.5);
    }

    .modal-content {
      background-color: #fefefe;
      margin: 10% auto;
      padding: 20px;
      border-radius: 5px;
      width: 80%;
      max-width: 500px;
    }

    .close {
      color: #aaa;
      float: right;
      font-size: 28px;
      font-weight: bold;
      cursor: pointer;
    }

    .close:hover {
      color: black;
    }

    .form-group {
      margin-bottom: 15px;
    }

    .form-group label {
      display: block;
      margin-bottom: 5px;
      font-weight: bold;
    }

    .form-group input,
    .form-group textarea {
      width: 100%;
      padding: 8px;
      box-sizing: border-box;
    }

    .modal-footer {
      text-align: right;
      margin-top: 20px;
    }
    
    .modal-footer button {
      margin-left: 10px;
    }
    
    .empty-state {
      text-align: center;
      padding: 40px 0;
    }
    
    .empty-state p {
      color: #6c757d;
      margin-bottom: 20px;
    }
    
    .loading-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.5);
      display: flex;
      justify-content: center;
      align-items: center;
      z-index: 1000;
      display: none;
    }
    
    .loading-spinner {
      border: 5px solid #f3f3f3;
      border-top: 5px solid #007bff;
      border-radius: 50%;
      width: 50px;
      height: 50px;
      animation: spin 1s linear infinite;
    }
    
    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
  </style>
</head>

<body>
  <div class="header">
    <h1>名片夹管理</h1>
  </div>
  <div class="container">
    <a href="main.html" class="back-link">← 返回主页</a>
    <div class="actions">
      <h2>名片夹列表</h2>
      <button id="addFolderBtn" class="success">新建名片夹</button>
    </div>

    <div id="folderList">
      <div class="loading">加载中...</div>
    </div>

  </div>

  <!-- 添加/编辑名片夹的模态框 -->
  <div id="folderModal" class="modal">
    <div class="modal-content">
      <span class="close">&times;</span>
      <h2 id="modalTitle">新建名片夹</h2>
      <form id="folderForm">
        <input type="hidden" id="folderId">
        <div class="form-group">
          <label for="folderName">名称</label>
          <input type="text" id="folderName" name="folderName" required>
        </div>
        <div class="form-group">
          <label for="folderDescription">描述</label>
          <textarea id="folderDescription" name="folderDescription" rows="3"></textarea>
        </div>
        <div class="modal-footer">
          <button type="button" id="cancelBtn">取消</button>
          <button type="submit" id="saveBtn">保存</button>
        </div>
      </form>
    </div>
  </div>

  <!-- 确认删除的模态框 -->
  <div id="confirmModal" class="modal">
    <div class="modal-content">
      <span class="close">&times;</span>
      <h2>确认删除</h2>
      <p>您确定要删除此名片夹吗？此操作将删除名片夹中的所有名片，且不可恢复。</p>
      <div class="modal-footer">
        <button type="button" id="cancelDeleteBtn">取消</button>
        <button type="button" id="confirmDeleteBtn" class="danger">删除</button>
      </div>
    </div>
  </div>
  
  <div class="loading-overlay" id="loadingOverlay">
    <div class="loading-spinner"></div>
  </div>

  <!-- 引入API文件和名片夹管理功能脚本 -->
  <script src="js/api.js"></script>
  <script src="js/folder-management.js"></script>
</body>

</html> 